package com.soFun.controller;

import com.soFun.service.AppInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 首页控制器，提供基本API端点
 */
@RestController
public class HomeController {

    private final AppInfoService appInfoService;

    @Autowired
    public HomeController(AppInfoService appInfoService) {
        this.appInfoService = appInfoService;
    }

    /**
     * 首页接口，用于验证应用程序启动成功
     * @return 包含应用信息的Map
     */
    @GetMapping("/")
    public Map<String, Object> home() {
        Map<String, Object> result = new HashMap<>();
        result.put("status", "success");
        result.put("message", "LearningAI API服务已成功启动");
        result.put("timestamp", System.currentTimeMillis());
        return result;
    }
    
    /**
     * 获取应用信息
     * @return 应用详细信息
     */
    @GetMapping("/info")
    public Map<String, Object> getAppInfo() {
        return appInfoService.getAppInfo();
    }
} 